<?
/**
 * This file is part of XNAT light.
 *
 * XNAT light is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * XNAT light is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with XNAT light.  If not, see <http://www.gnu.org/licenses/>.
 */
namespace NRG\Xnat;

use NRG\Exceptions as Exceptions;
use NRG\Framework as Framework;

/**
 * XNAT user model
 *
 * @package NRG\Xnat
 */
class User extends XObject
{
    /**
     * Username
     *
     * @var string
     */
    protected $_username;

    /**
     * Email address
     *
     * @var string
     */
    protected $_email;

    /**
     * Constructor
     */
    public function __construct()
    {
	parent::__construct();
    }

    /**
     * Set username
     * 
     * @param string $username
     */
    public function setUsername($username=null)
    {

	if(!is_string($username))
    {
        throw new Framework\Exceptions\IllegalArgumentException("Username must be a string");
    }

	if($username == "")
	    throw new Framework\Exceptions\IllegalArgumentException("Username cannot be null");

	$this->_username = $username;
    }

    /**
     * Set database id
     *
     * @param int $id
     */
    public function setID($id=null)
    {
	if(!is_int($id))
	    throw new Framework\Exceptions\IllegalArgumentException("ID must be an integer");

	if($id < 0)
	    throw new Framework\Exceptions\IllegalArgumentException("ID must be >= 0");

	$this->_id = $id;
    }

    /**
     * Retrieve username
     * 
     * @return string
     */
    public function getUsername()
    {
	return $this->_username;
    }

    /**
     * Get database ID
     *
     * @return int
     */
    public function getID()
    {
	return $this->_id;
    }

    /**
     * Set email address
     *
     * @param string $email
     */
    public function setEmail($email)
    {
	if(!is_string($email))
	    throw new Framework\Exceptions\IllegalArgumentException("Email must be a string");

	$email = trim($email);

	if($email == "")
	    throw new Framework\Exceptions\IllegalArgumentException("Email cannot be emoty");

	$this->_email = $email;
    }

    /**
     * Get email address
     *
     * @return string
     */
    public function getEmail()
    {
	return $this->_email;
    }
}
